﻿Public Class Task
    Implements IObject
    Dim id As Integer
    Dim name As String
    Dim estimatedStartDate As Date
    Dim estimatedEndDate As Date
    Dim startDate As Date
    Dim endDate As Date
    Dim observations As String
    Dim taskType As TaskType
    Dim projectActivity As ProjectActivity
    Dim state As State
    Dim projectMember As ProjectMember
    Dim progressTask As ArrayList

    Public Sub New()
    End Sub

    Public Sub New(ByRef state As State)
        Me.state = state
    End Sub

    Public Sub New(ByVal id As Integer)
        Me.id = id
    End Sub

    Public Sub New(ByVal id As Integer, ByVal name As String, ByVal estimatedStartDate As Date, ByVal estimatedEndDate As Date, ByVal startDate As Date, ByVal endDate As Date, ByVal observations As String, ByRef taskType As TaskType, ByRef projectActivity As ProjectActivity, ByRef state As State, ByRef projectMember As ProjectMember)
        Me.id = id
        Me.name = name
        Me.estimatedStartDate = estimatedStartDate
        Me.estimatedEndDate = estimatedEndDate
        Me.startDate = startDate
        Me.endDate = endDate
        Me.observations = observations
        Me.taskType = taskType
        Me.projectActivity = projectActivity
        Me.state = state
        Me.projectMember = projectMember
    End Sub

    Public Function getTableName() As String Implements IObject.getTableName
        Return "TASKS"
    End Function

    Public Function getId() As Integer Implements IObject.getId
        Return id
    End Function

    Property idProperty() As Integer
        Get
            Return Me.id
        End Get
        Set(ByVal value As Integer)
            Me.id = value
        End Set
    End Property

    Property nameProperty() As String
        Get
            Return Me.name
        End Get
        Set(ByVal value As String)
            Me.name = value
        End Set
    End Property

    Property estimatedStartDateProperty() As Date
        Get
            Return Me.estimatedStartDate
        End Get
        Set(ByVal value As Date)
            Me.estimatedStartDate = value
        End Set
    End Property

    Property estimatedEndDateProperty() As Date
        Get
            Return Me.estimatedEndDate
        End Get
        Set(ByVal value As Date)
            Me.estimatedEndDate = value
        End Set
    End Property

    Property startDateProperty() As Date
        Get
            Return Me.startDate
        End Get
        Set(ByVal value As Date)
            Me.startDate = value
        End Set
    End Property

    Property endDateProperty() As Date
        Get
            Return Me.endDate
        End Get
        Set(ByVal value As Date)
            Me.endDate = value
        End Set
    End Property

    Property observationsProperty() As String
        Get
            Return Me.observations
        End Get
        Set(ByVal value As String)
            Me.observations = value
        End Set
    End Property

    Property taskTypeProperty() As TaskType
        Get
            Return (Me.taskType)
        End Get
        Set(ByVal value As TaskType)
            Me.taskType = value
        End Set
    End Property

    Property projectActivityProperty() As ProjectActivity
        Get
            Return Me.projectActivity
        End Get
        Set(ByVal value As ProjectActivity)
            Me.projectActivity = value
        End Set
    End Property

    Property stateProperty() As State
        Get
            Return Me.state
        End Get
        Set(ByVal value As State)
            Me.state = value
        End Set
    End Property

    Property projectMemberProperty() As ProjectMember
        Get
            Return Me.projectMember
        End Get
        Set(ByVal value As ProjectMember)
            Me.projectMember = value
        End Set
    End Property

    Property progressTaskProperty() As ArrayList
        Get
            Return Me.progressTask
        End Get
        Set(ByVal value As ArrayList)
            Me.progressTask = value
        End Set
    End Property

    Public Function getTaskState() As TaskState
        Dim taskState As TaskState = Nothing

        Select Case stateProperty.idProperty
            Case state.TASK_STATE_IN_PLANNING_ID
                taskState = New TaskStateInPlanning
            Case state.TASK_STATE_IN_PROCESS_ID
                taskState = New TaskStateInProcess
            Case state.TASK_STATE_COMPLETED_ID
                taskState = New TaskStateCompleted
        End Select

        Return taskState
    End Function
End Class
